<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/website/layout/tag.jsp"%>
<script type="text/javascript">
	$(document).ready(
		function() {
			//事件注册.
			//"新增"按钮点击事件注册.
			$("#newBtn").click(newRole);
			//"编辑"按钮点击事件注册.
			$("#modifyBtn").click(modifyRole);
			//"删除"按钮点击事件注册.
			$("#deleteBtn").click(deleteRole);
			
			//checkbox控件事件注册.
			$("[name='chkAll']").each(
				function() {
					$(this).click(function() {
						checkAll("chkAll", "chkEach");
					});
				}
			);
			$("[name='chkEach']").each(
				function() {
					$(this).click(function() {
						checkEach("chkAll", "chkEach");
					});
				}
			);
			
			//设置左菜单对应菜单CSS为选中状态.
			changeToActiveCss("menu_7015");
			
			//消息显示.
			var msg = '<c:out value="${msg}"/>';
			if (msg != "") {
				alert(msg);
			}
		}
	);
	
	function newRole() {
		window.location.href='${pageContext.request.contextPath}/system/enterRuleModify.action?oper=new';
	}
	
	function modifyRole() {
		var checkObjs = $(":checkbox[name='chkEach']:checked");
		var len = checkObjs.length;
		if (len == 0) {
			alert("请选择要编辑的角色.");
			return false;
		}
		
		if (len > 1) {
			alert("请只选择一条角色.");
			return false;
		}
		
		window.location.href='${pageContext.request.contextPath}/system/enterRuleModify.action?oper=modify&sysId=' + checkObjs[0].value;
	}
	
	function deleteRole() {
		var roleIds = "";
		$(":checkbox[name='chkEach']:checked").each(
			function() {
				roleIds += $(this).val() + ",";
			}
		);
		
		if (roleIds == "") {
			alert("请选择要删除的角色。");
			return false;
		}
		
		if (confirm("是否删除角色?")) {
			window.location.href='${pageContext.request.contextPath}/system/deleteRole.do?roleIds=' + roleIds;
		}
	}
</script>
<div id="content_right">
	<div style="width:100%;height:35px;line-height:35px;text-align:left;background-color:#F5FAFA;font-weight:bold; ">系统管理 > 管理员 > 角色列表</div>
	<div id="btnArea">
		<div class="buttons">
			<a id="newBtn" href="#" style=""><!-- class="regular"-->
				<img src="../images/btn_apply.png" alt=""/> 
				新增
			</a>
			<a id="modifyBtn" href="#" style=""><!-- class="regular"-->
				<img src="../images/btn_apply.png" alt=""/> 
				编辑
			</a>
			<a id="deleteBtn" href="#" class="regular"><!-- class="regular"-->
				<img src="../images/btn_cross.png" alt=""/> 
				删除
			</a>
		</div>
	</div>
	<div style="clear:both; "></div>
	<div id="resultArea" style="height:500px; ">
		<table class="dataTable" cellspacing="0"> 
			<tr> 
			<th scope="col" width="26px;"><input type="checkbox" name="chkAll"/></th> 
			<th scope="col" width="120px">角色名</th> 
			<th scope="col" width="120px">角色级别</th>
			<th scope="col" width="120px">角色状态</th>
			<th scope="col" width="400px">角色备注</th>  
			</tr> 
			<c:if test="${not empty ruleList}">
				<c:forEach items="${ruleList}" var="rule" varStatus="status">
					<tr> 
						<td class="row"> 
							<input type="checkbox" name="chkEach" value="${rule.id }">	
						</td>
						<td class="row">
							${rule.name }
						</td> 
						<td class="row">
							${rule.viewSys }
						</td> 
						<td class="row" >
							${rule.viewEnable }
						</td> 
						<td class="row" > 
							${rule.dsc }
						</td>  
					</tr> 
				</c:forEach>
			</c:if>
		</table> 
	</div>
</div>
